/*
 * @Author       : Bing Chen chenbing@iocharger.com
 * @Date         : 2024-05-20 22:39:53
 * @LastEditors  : Bing Chen chenbing@iocharger.com
 * @LastEditTime : 2025-03-15 12:44:45
 * @FilePath     : \openchaoji-corelib\evcc\include\OpenChaoJi_evcc_app.h
 * @Description  : 本文件声明OpenChaoJi库提供给evcc的app调用的接口
 *
 * Copyright (c) 2025 OpenChaoJi
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the icense for the specific language governing permissions and
 * limitations under the License.
 *
 */


#ifndef __OPEN_CHAOJI_EVCC_APP_H__
#define __OPEN_CHAOJI_EVCC_APP_H__

/**
 * 本文件定义OpenChaoJi库提供给evcc的app调用的接口
 */
struct OpenChaoJi_evcc_app_start_parameter
{
#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B == CONFIG_YES)
    // 功能协商, 各数组按照优先级排序, 0表示结束
    uint8_t fdc_auth[8];         // enum SystemB_FDCType 车辆支持的鉴权功能模块FDC编码,
    uint8_t fdc_reserve[8];      // enum SystemB_FDCType 车辆支持的预约功能模块FDC编码
    uint8_t fdc_selfcheck[8];    // enum SystemB_FDCType 车辆支持的系统自检功能模块FDC编码
    uint8_t fdc_supply[8];       // enum SystemB_FDCType 车辆支持的供电模式功能模块FDC编码
    uint8_t fdc_energy[8];       // enum SystemB_FDCType 车辆支持的预充及能量传输功能模块FDC编码
    uint8_t fdc_statistics[8];   // enum SystemB_FDCType 车辆支持的服务统计功能模块FDC编码
    uint8_t fdc_service_idle[8]; // enum SystemB_FDCType 车辆支持的服务空闲功能模块FDC编码
#endif

    // 参数配置
    uint16_t parameter_max_charging_curr;      // SystemB_CurrentType  车辆最高允许充电电流
    uint16_t parameter_max_charging_volt;      // SystemB_VoltageType1 车辆最高允许充电总电压
    uint16_t parameter_max_charging_energy;    // SystemB_CapacityType 车辆最高允许输入总能量
    uint16_t parameter_soc;                    // SystemB_SOCType      车辆当前荷电状态
    uint16_t parameter_max_battery_volt;       // SystemB_VoltageType2 车辆蓄电池电芯组最高允许电压
    uint8_t parameter_max_battery_temperature; // SystemB_TemperatureType1 车辆蓄电池电芯组最高允许温度
    uint16_t parameter_max_discharge_energy;   // SystemB_CapacityType 车辆最高允许放电总能量
    uint16_t parameter_min_discharge_volt;     // SystemB_VoltageType1 车辆最低放电电压
    uint16_t parameter_max_discharge_curr;     // SystemB_CurrentType  车辆最大放电电流
    uint16_t parameter_min_discharge_curr;     // SystemB_CurrentType  车辆最小放电电流
};

#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B == CONFIG_YES)
/**
 * @brief: B类系统当Auth协商时需要App确认车辆是否同意等待鉴权
 * @param {OpenChaoJi_evcc_context *} context
 * @return {*}
 */
int OpenChaoJi_evcc_app_get_auth_status(struct OpenChaoJi_evcc_context * context);
#endif

// 车辆充电需求参数
struct OpenChaoJi_evcc_gbt27930_charging_requirement_parameter
{
    uint16_t voltage;    // VoltageType1, WORD
    uint16_t current;    // CurrentType, WORD
    uint8_t charge_mode; // enum SystemB_ChargeModeType
};
/**
 * @brief: 能量传输阶段, lib需要向App请求电压电流和充电模式信息, 用于发送给SECC
 *         该信息需要有车端BMS决定, 本Lib无法自行计算得出
 * @param {OpenChaoJi_evcc_context} *context
 * @param {OpenChaoJi_evcc_gbt27930_charging_requirement_parameter} *charging_requirement_evcc
 * @return {*}
 */
void OpenChaoJi_evcc_app_get_charging_requirement(struct OpenChaoJi_evcc_context *context, struct OpenChaoJi_evcc_gbt27930_charging_requirement_parameter *charging_requirement_evcc);

#endif
